package com.zpself.module.算法练习.多线程;

import org.junit.Test;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;

/**
 * @author By ZengPeng
 * @Description
 * @date in  2021/3/2 17:57
 * @Modified By
 */
public class 十线程加加十次最小值 {
    private int i=0;
    @Test
    public  void  add() throws  InterruptedException {
        ExecutorService executorService = Executors.newFixedThreadPool(10);
        List<Future<Date>> list = new ArrayList<>();
        for (int k = 0; k < 10; k++) {
          executorService.submit(() -> {
              for (int j = 0; j <10; j++) {
                   ++i;
              }
          });
        }
        Thread.sleep(2000);
        System.out.println(i);
    }
}
